package com.electron.power.octopus;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.mongodb.core.CollectionOptions;
import org.springframework.data.mongodb.core.MongoOperations;

import com.electron.power.model.mod.ModStr;

@SpringBootApplication
public class ModDataWebApplication {

	public static void main(String[] args) {
		SpringApplication.run(ModDataWebApplication.class, args);
	}
	
	@Bean   //启动时执行
    public CommandLineRunner initData(MongoOperations mongo) {  // 2
        return (String... args) -> {    // 3
            mongo.dropCollection(ModStr.class);    // 4
            mongo.createCollection(ModStr.class, CollectionOptions.empty().maxDocuments(20).size(10000).capped()); // 5
        };
    }
}